﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using Model;
using System.Data.SqlClient;

namespace BLL
{
    public class LocationBLL
    {
        LocationDAL dal = new LocationDAL();

        /// <summary>
        /// 显示区位勘察
        /// </summary>
        /// <returns></returns>
        public List<Location> ShowLocation()
        {
            return dal.Show();
        }

        /// <summary>
        /// 查找对应项目的区位信息
        /// </summary>
        /// <returns></returns>
        public List<Location> ShowLocation(string projectNumber)
        {
            SqlParameter[] sp1 = new SqlParameter[]{
                  new SqlParameter("projectNumber",projectNumber)
            };
            return dal.Show(sp1);
        }


        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageCount"></param>
        /// <returns></returns>
        public List<Location> PaperLocation(int PageIndex, int PageSize, out int PageCount)
        {
            PageCount = dal.Show().Count();
            return dal.Show().Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
        }
        /// <summary>
        /// 添加区位勘察
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool AddLocation(Location m)
        {
            return dal.Add(m);
        }
        /// <summary>
        /// 删除区位勘察
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool DelLocation(Location m)
        {
            return dal.Del(m);
        }

        /// <summary>
        /// 查询单个区位勘察信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Location BackLocation(int id)
        {
            return dal.Back(id);
        }

        /// <summary>
        /// 修改区位勘察信息
        /// </summary>
        /// <param name="m"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdLocation(Location m, int id)
        {
            return dal.Update(m, id);
        }
    }
}
